package com.nantai.jiafang.nantaijiafang.deviceManager.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.Patrol;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.Task;

import java.util.List;

/**
 * Created by xxfreedom on 2017/2/12.
 */

public class CheckTaskAdapter extends BaseAdapter {
    private List<Task> taskList;
    private LayoutInflater inflater;
    public CheckTaskAdapter() {}

    public CheckTaskAdapter(List<Task> taskList, Context context) {
        this.taskList = taskList;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return taskList==null?0:taskList.size();
    }

    @Override
    public Task getItem(int position) {
        return taskList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.task_item,null);
        Task task=getItem(position);
        TextView tv_place= (TextView) view.findViewById(R.id.place_tv);
        TextView tv_count= (TextView) view.findViewById(R.id.count_tv);
        TextView tv_status= (TextView) view.findViewById(R.id.process_tv);
        TextView tv_last= (TextView) view.findViewById(R.id.last_tv);
        tv_place.setText("库位:  "+task.getName());
        tv_count.setText("设备数量:  "+task.getDevice_count());
        tv_last.setText("最后一次盘点时间:  "+(task.getLast_task()==null?"":task.getLast_task()));
        tv_status.setText("状态:  "+(task.getIs_task()==1?"盘点中":"未盘点"));
        return view;
    }
}
